package com.zsrt.jmj.children.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zsrt.jmj.children.service.ChildrenService;
import com.zsrt.jmj.children.service.impl.ChildrenServiceImpl;
import com.zsrt.jmj.utils.GsonUtil;


public class ChildrenController extends HttpServlet {
	private static final long serialVersionUID = 1L;
    
	private ChildrenService service= new ChildrenServiceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    	String method = req.getParameter("method");
    	
    	Map<String, Object> map = new HashMap<>();
    	if(!"".equals(method) && null != method){
    		if(method.equals("findAllPositions")){
    			
				service.findAllPositions(map);
    		}else if("findAllEducations".equals(method)){
    			
    			service.findAllEducations(map);
    		}else if("findAll".equals(method)){
    			//根据父节点来查询子节点  
    			
    			//页面上只需要给一个父ID
    			String fatherId = req.getParameter("fatherId");
    			service.findAll(fatherId,map);
    		}
    	}
    
    	GsonUtil.printJson(resp, map);
    }
}
